﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace BallWar
{
    class Floor
    {
        public Color BackColor { get; set; }
        public Size Size { get; set; }
        public List<Bean> Beans = new List<Bean>();
        public Graphics g { get; set; }
        public Ball ball { get; set; }
        public Floor(Graphics g)
        {
            this.g = g;
            this.ball = new Ball(Color.Blue, new Point(60, 60), this.g);
            this.BackColor = Color.Gray;
            this.Size = new Size(500, 500);
        }
        public void AddBean()
        {
            Random r1 = new Random();
            Random r2 = new Random();
            Bean bean = new Bean(new Point(r1.Next(Size.Width), r2.Next(Size.Height)), this.g);
            Beans.Add(bean);
        }
        public void Draw()
        {
            foreach (Bean bean in Beans)
            {
                if(Math.Sqrt( Math.Abs(bean._station.X-ball._station.X)+ Math.Abs(bean._station.Y - ball._station.Y)) <= ball._size.Width / 2)
                {
                    ball.Grow();
                    bean.UnDisplay();
                }
            }
        }
    }
}
